<?php
/**
 * 后台促销控制器
 * @author Max.Yu <max@jipu.com>
 */

namespace Admin\Controller;

class PromoteController extends AdminController{

  /**
   * 促销工具列表
   * @author Max.Yu <max@jipu.com>
   */
  public function index(){
    //记录当前列表页的Cookie
    Cookie('__forward__', $_SERVER['REQUEST_URI']);
    $this->meta_title = '营销工具';
    $menus = $this->getMenus();
    $list = $this->_checkDiff($menus['child']['促销管理'],$this->_promoteList());
    $this->assign('data',$list);
    $this->display();
  }

  /**
   * 营销活动列表
   * @return [type] [description]
   */
  private function _promoteList(){
    $list = array(
        '0'=>array(
          'url'=>'RedPackage/index',
          'ename'=>'redpacket',
          'title'=>'红包',
          'class'=>'danger-dark'),
        '1'=>array(
          'url'=>'Advertise/index',
          'ename'=>'advertise',
          'title'=>'广告',
          'class'=>'info'),
        '2'=>array(
          'url'=>'Coupon/index',
          'ename'=>'coupon',
          'title'=>'优惠券',
          'class'=>'warning'),
        '3'=>array(
          'url'=>'Card/index',
          'ename'=>'vipcard',
          'title'=>'礼品卡',
          'class'=>'success'),
        '4'=>array(
          'url'=>'Invite/index',
          'ename'=>'invite',
          'title'=>'邀请',
          'class'=>'success'),
        '5'=>array(
          'url'=>'Activity/index',
          'ename'=>'activity',
          'title'=>'专题',
          'class'=>'danger'),
        '6'=>array(
          'url'=>'Manjian/index',
          'ename'=>'manjian',
          'title'=>'满减',
          'class'=>'info'),
        '7'=>array(
          'url'=>'SecondPieces/index',
          'ename'=>'banjia',
          'title'=>'第二件折扣',
          'class'=>'success'),
        '8'=>array(
          'url'=>'BuySend/index',
          'ename'=>'zeng',
          'title'=>'买送',
          'class'=>'warning'),
        '9'=>array(
          'url'=>'SeckillActivity/index',
          'ename'=>'activity',
          'title'=>'秒杀',
          'class'=>'info'),
        '10'=>array(
          'url'=>'Fugou/index',
          'ename'=>'manjian',
          'title'=>'老客户立减',
          'class'=>'danger')
      );
    return $list;
  }

  /**
   * 营销工具展现与否
   * @param  [type] $arr  [description]
   * @param  [type] $list [description]
   * @return [type]       [description]
   */
  private function _checkDiff( $arr, $list ){

    $data = array();

    foreach ($list as $key => $value) {
      foreach ($arr as $k => $v) {
        if ($value['url'] == $v['url']) {
          $data[] = $value;
        }
      }
    }
    return $data;
  }

}